<?php 

$response = array();

require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();

if(isset($_GET['idTypeFood'])){
	
	$idTypeFood = $_GET['idTypeFood'];
	
	mysql_query("set names 'utf8'");
	
	$result = mysql_query("SELECT * FROM LOAI_MON_AN WHERE id= $idTypeFood")
	 	or die(mysql_error());
	// check for empty result
	if (mysql_num_rows($result) > 0) {
		$response["type_food_id"] = array();
		
		$row = mysql_fetch_array($result);
		
		$typeFood = array();
		$typeFood['id'] = $row['id'];
		$typeFood['TEN_LOAI_MON_AN'] = $row['TEN_LOAI_MON_AN'];
		
		array_push($response["type_food_id"], $typeFood);
		
		// success
		$response["success"] = 1; 
		echo utf8_encode(json_encode($response));
	}
	else {
		// no products found
		$response["success"] = 0;
		$response["message"] = "No type food found";
		
		// echo no users JSON
		print utf8_encode(json_encode($response));
	}
	
}else {
	$response["success"] = 0;
	$response["message"] = "Required field(s) is missing";
	echo json_encode($response);
}
?>